import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        userInfo: JSON.parse(localStorage.getItem("userInfo")) || {}
    },
    mutations: {
        setInfo(state, info) {
            localStorage.setItem("userInfo", JSON.stringify(info));
            state.userInfo = info;
        }
    },
    actions: {},
    modules: {},
    getters: {
        getUserInfo(state) {
            return state.userInfo;
        }
    }
})
